package com.carlinfo.back.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 *登陆后的首页 
 */
public class AdminsBackServlet extends HttpServlet
{
private Logger logger = LogManager.getLogger() ; 
	
	@Override
	protected void service(HttpServletRequest request, 
			HttpServletResponse response) throws ServletException, IOException
	{
		logger.info("==AdminsBackServlet=service==");
		/* 取信的内容;取单个
		 * http://127.0.0.1:8080/userscenter/NoLoginBackServlet?method=login&a=1&b=2&c=3
		 * 参数是键,返回值就是值
		 *  */
		String method = request.getParameter("method");
		logger.info("==method:{}==",method);
		
		if("main".equalsIgnoreCase(method))
		{
			/* 首页 */
			this.main(request,response);
		}else if("welcome".equalsIgnoreCase(method))
		{
			/* 欢迎页面 */
			this.welcome(request,response);
		}
	}
	
	/**
	 * 欢迎页面
	 * @param request
	 * @param response
	 * @throws IOException 
	 * @throws ServletException 
	 */
	private void welcome(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		logger.info("==welcome==");
		/* 打开登陆页 */
		String path = "/WEB-INF/jsp/back/admins/welcome.jsp";
		/* 服务器端跳转 */
		request.getRequestDispatcher(path).forward(request, response);
	}

	/**
	 *  登陆后的首页
	 * @param request
	 * @param response
	 * @throws IOException 
	 * @throws ServletException 
	 */
	private void main(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		logger.info("==main==");
		/* 打开登陆页 */
		String path = "/WEB-INF/jsp/back/admins/main.jsp";
		/* 服务器端跳转 */
		request.getRequestDispatcher(path).forward(request, response);
	}
}
